/**
 * Created by Administrator on 2016/12/1 0001.
 */
app.controller("character",["$scope",'$location',function($scope,$location){
    $("a").click(function(e){
        e.preventDefault();
    });
    $(".remove").click(function(){
        $(".deleteCharacter").show();
    });
    $scope.deleteCharacter = function(){
        $(".deleteCharacter").hide();
    };
    $scope.cancelDeleteCharacter = function(){
        $(".deleteCharacter").hide();
    };
    $('input').iCheck({
        checkboxClass: 'icheckbox_minimal-green',
        radioClass: 'iradio_minimal-green',
        increaseArea: '20%' // optional
    });
}]);
app.controller("characterTable",["$scope",function(){
    $('#characterTable').bootstrapTable({
        columns: [
            {
                checkbox: true
            },{
                field: 'roleName',
                title: '角色名称',
                align:"left",
                halign:"center"
            }, {
                field: 'description',
                title: '描述',
                align:"left",
                halign:"center"
            }],
        data: [
            {
                roleName:"APP用户",
                description:"APP登录用户，PC端不能登录"
            },{
                roleName:"系统管理员",
                description:"系统管理员"
            },{
                roleName:"APP用户",
                description:"APP登录用户，PC端不能登录"
            },{
                roleName:"系统管理员",
                description:"系统管理员"
            },{
                roleName:"APP用户",
                description:"APP登录用户，PC端不能登录"
            },{
                roleName:"系统管理员",
                description:"系统管理员"
            },{
                roleName:"APP用户",
                description:"APP登录用户，PC端不能登录"
            },{
                roleName:"系统管理员",
                description:"系统管理员"
            },{
                roleName:"APP用户",
                description:"APP登录用户，PC端不能登录"
            },{
                roleName:"系统管理员",
                description:"系统管理员"
            },{
                roleName:"APP用户",
                description:"APP登录用户，PC端不能登录"
            },{
                roleName:"系统管理员",
                description:"系统管理员"
            }
        ],
        pagination :true,
        paginationLoop: false,
        striped :true,
        paginationPreText : "上一页",
        paginationNextText :"下一页",
        undefinedText : "暂无数据",
        showColumns :true,
        showExport : true,
        showRefresh :true,
        height:711,
        showPaginationSwitch:true,
        pageSize:15,
        pageList :[10,15,20]
    });
}]);
app.controller("characterAllotCtrl",["$scope",'$location',function($scope,$location){
    //treView
    $(function () {
        function getTree() {
            var data = [{
                text: "菜单",
                backColor:"#48AB5D",
                color:"#fff",
                selectable: false,
                nodes: [
                    {
                        text: "无人机数据",
                        id: '00001',
                        nodeId: '00001'
                    }, {
                        text: "权限系统",
                        id: '00002',
                        nodeId: '00002'
                    }, {
                        text: "外观管理",
                        id: '00003',
                        nodeId: '00003'
                    }, {
                        text: "组件",
                        id: '00004',
                        nodes: [
                            {
                                text: '导航菜单',
                                id: '00005',
                                nodeId: '00005'
                            }]
                    }, {
                        text: "日志管理",
                        id: '00006',
                        nodeId: '00006'
                    }, {
                        text: "实时监测",
                        id: '00007',
                        nodeId: '00007'
                    }, {
                        text: "大气质量等级",
                        id: '00008',
                        nodeId: '00008'
                    }, {
                        text: "空气质量报告",
                        id: '00009',
                        nodeId: '00009'
                    }, {
                        text: "综合指数",
                        id: '00010',
                        nodeId: '00010'
                    }, {
                        text: "优良天数",
                        id: '00011',
                        nodeId: '00011'
                    }, {
                        text: "GPRS信息",
                        id: '00012',
                        nodeId: '00012'
                    }, {
                        text: "油烟设备管理",
                        id: '00013',
                        nodeId: '00013'
                    }, {
                        text: "环保部数据",
                        id: '00014',
                        nodeId: '00014'
                    }, {
                        text: "油烟监测",
                        id: '00015',
                        nodeId: '00015'
                    }, {
                        text: "大气监测设备数据",
                        id: '00016',
                        nodeId: '00016'
                    }, {
                        text: "油烟历史记录",
                        id: '00017',
                        nodeId: '00017'
                    }]
            }];
            return data;
        }
        // $('#character-allot-tree').treeview({
        //     data: getTree(),         // data is not optional
        //     selectedBackColor:"#fff",
        //     selectedColor:"#333"
        // });
    });
    //    zTreee
    var setting = {	};

    var zNodes =[
        { name:"菜单", open:true,
            children: [
                { name:"权限管理",
                    children: [
                        { name:"账号管理"},
                        { name:"用户管理"},
                        { name:"菜单管理"},
                        { name:"角色管理"}
                    ]
                },
                { name:"外观管理",
                    children: [
                        { name:"主题"},
                        { name:"布局"},
                        { name:"皮肤"}
                    ]
                },
                { name:"无人机数据", isParent:true}
            ]},
        { name:"资源",
            children: [
                { name:"图片", open:true,
                    children: [
                        { name:"icon"},
                        { name:"zTree"},
                        { name:"页面"},
                        { name:"表单"}
                    ]
                },
                { name:"郑州",
                    children: [
                        { name:"区域"},
                        { name:"行政规划"},
                        { name:"小型站"},
                        { name:"国控站"}
                    ]
                },
                { name:"样式",
                    children: [
                        { name:"表单"},
                        { name:"zTree"},
                        { name:"公共"},
                        { name:"组件"}
                    ]
                }
            ]
        }
    ];

    $(document).ready(function(){
        $.fn.zTree.init($("#character-allot-tree"), setting, zNodes);
    });
}]);

app.controller("characterAllotUser",["$scope",function(){
    $(function () {
        var demo2 = $('.demo1').bootstrapDualListbox({
            nonSelectedListLabel: '未分配用户',
            selectedListLabel: '已分配用户',
            preserveSelectionOnMove: 'moved',
            moveAllLabel:"移动所有",
            removeAllLabel:"移除所有",
            infoText:" ",
            infoTextEmpty:" ",
            filterPlaceHolder:"请输入要搜索的内容",
            moveOnSelect: true
        });
        $(".moveall").html('<i class="glyphicon glyphicon-chevron-right"></i><i class="glyphicon glyphicon-chevron-right"></i> ');
        $(".removeall").html('<i class="glyphicon glyphicon-chevron-left"></i><i class="glyphicon glyphicon-chevron-left"></i> ');
        $(".bootstrap-duallistbox-container>div").each(function(){
            $(this).append(`
            <ul class="pagingDetail pull-left" style="margin-top: 5px;">
                <li><a href="#">共<span>10</span>条 每页：<span>10</span>条</a></li>
            </ul>
            <ul class="pagination pull-right" style="margin-top: 5px;">
                <li><a href="#">上一页</a></li>
                <li><a href="#">下一页</a></li>
            </ul>`
            )
        });
        $("a").click(function(e){
            e.preventDefault();
        });
        $('input').iCheck({
            checkboxClass: 'icheckbox_minimal-green',
            radioClass: 'iradio_minimal-green',
            increaseArea: '20%' // optional
        });
    });
}]);